/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package theserver;

import java.io.IOException;
import java.net.ServerSocket;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Emma
 */
public class ServerSocketConnection implements Runnable {

    private int port;
    private Controller controller;
    private Thread thread = new Thread(this);
    private ServerSocket serverSocket;
    private boolean threadRun = true;
    
    public ServerSocketConnection(int port, Controller controller) {
        try {
            this.port = port;
            this.controller = controller;
            serverSocket = new ServerSocket(port);
            thread.start();
        } catch (IOException ex) {
            Logger.getLogger(ServerSocketConnection.class.getName()).log(Level.SEVERE, null, ex);
        }


    }

    public void run() {
        
        while(threadRun){
            try {
                ConnectedDevice con = new ConnectedDevice(serverSocket.accept(), controller);
            } catch (IOException ex) {
                Logger.getLogger(ServerSocketConnection.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
}
